package com.example.demo.service.impl;

import com.example.demo.dao.PhysicalMapper;
import com.example.demo.modal.Physical;
import com.example.demo.service.PhysicalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PhysicalServiceImpl implements PhysicalService{
    @Autowired
    PhysicalMapper physicalMapper;

    public List<Physical> findAll(){
        return physicalMapper.selectAll();
    };

    @Override
    public int save(Physical physical){
        return physicalMapper.insert(physical);
    };

    @Override
    public int deleteById(int id){
        return physicalMapper.deleteByPrimaryKey(id);
    };

    @Override
    public int update(Physical physical){
        return physicalMapper.updateByPrimaryKey(physical);
    };

    @Override
    public List<Physical> findById(int id){
        return physicalMapper.selectByPrimaryKey(id);
    };

    @Override
    public List<Physical> findByName(String name){
        return physicalMapper.selectByName(name);
    };

    @Override
    public List<Physical> findByPId(int pid){
        return physicalMapper.selectByPId(pid);
    };

    @Override
    public int selectMaxId(){
        return physicalMapper.selectMaxId();
    }
}
